<!--
 * @Description: 
 * @Author: mmzhang
 * @Date: 2023-01-06 17:10:24
 * @LastEditTime: 2023-01-10 16:01:44
-->
<template>
  <dt-modal-edit ref='modal' title='审核' :label-width='130' :width='500' @ok='onOk' :loading='loading'>
    <preview-image ref="previewImage" :images="info.picUrlList" showDownLoad :showIndex="imageIndex"/>
  </dt-modal-edit>
</template>

<script>
  import Opt from '../opt/AuditOpt.js'
  import infoMgr from '@/biz/base/info'
  import auditMgr from '@/biz/flowApproval/processAudit.js'
  export default {
    data() {
      return {
        info: {
          auditResultFlag: null,
          auditReason: '',
          picUrlList: []
        },
        loading: false,
        imageIndex: 0,
      }
    },
    mounted() {
    },
    methods: {
      show(info) {
        Object.assign(this.info, info)
        this.$refs.modal.show(new Opt(this.info, this.$route.name, (file) => {
          this.imageIndex = this.info.picUrlList.indexOf(file.url)
          this.$refs.previewImage.show()
        }))
      },
      hide() {
        this.$refs.modal.hide()
      },
      onOk() {
        this.loading = true
        let annexListObj = {
          annexList:this.info.picUrlList
        }
        auditMgr
          .audit({
            auditId: this.$route.query.auditId,
            auditResultFlag: this.info.auditResultFlag,
            auditReason: this.info.auditReason,
            auditFile:this.info.picUrlList.length?JSON.stringify(annexListObj):''
          })
          .then((res) => {
            this.loading = false
            this.$store.commit('deleteroutefun', '审核文章内容')
            this.$Message.success('审核文章内容成功!')
            this.$router.go(-1)
          })
          .catch(() => {
            this.loading = false
          })
      }
    }
  }
</script>

<style>
</style>
